package com.axxc.cloud.config;

import javax.annotation.PostConstruct;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SuppressWarnings("restriction")
@Configuration
@EnableSwagger2
@EnableWebMvc
public class SwaggerConfig {

	@PostConstruct
	public void postConstruct() {
		System.err.println("-------------->启用SwaggerUI");
	}
	
    @Bean
    public Docket userApi() {
        return new Docket(DocumentationType.SWAGGER_2)
        		.groupName("axxc组")
                .select()  // 选择那些路径和api会生成document
                .apis(RequestHandlerSelectors.basePackage("com.axxc.cloud.controller.axxc"))
                .paths(PathSelectors.any()) // 对所有路径进行监控
                .build()
                .apiInfo(userInfo());
    }
    @Bean
    public Docket openApi() {
    	return new Docket(DocumentationType.SWAGGER_2)
    			.groupName("open组")
    			.select()  // 选择那些路径和api会生成document
    			.apis(RequestHandlerSelectors.basePackage("com.axxc.cloud.controller.open"))
    			.paths(PathSelectors.any()) // 对所有路径进行监控
    			.build()
    			.apiInfo(userInfo());
    }



    private ApiInfo userInfo() {
        ApiInfo apiInfo = new ApiInfo("SSM-Swagger-Rest文档",//大标题
                "含通用mapper,分页插件pagehelper",//小标题
                "v1.0-beta",//版本
                "武汉",
                new Contact("xxc", "https://gitee.com/biuabiu", "545597162@qq.com"),// 作者
                "SwaggerRest-URL",//链接显示文字
                ""//网站链接
        );
        return apiInfo;
    }

}
